package cn.gov.msa.collection;

import cn.gov.msa.model.UserDetail;
import cn.gov.msa.util.PropertiesTools;
import cn.gov.msa.util.WebServiceTools;
import net.sf.json.JSONObject;


public class AppLdapService {

	private static String  url = PropertiesTools.readProperties("app.url");
	
	public static UserDetail getUserDetail(String token, Integer isrole) throws Exception{
		UserDetail userDetail = new UserDetail();
		
		JSONObject param = new JSONObject();
		
		param.put("tokenString", token);
        String[] parameter = new String[]{param.toString()};   
    	JSONObject jsonResult = JSONObject.fromObject(WebServiceTools.getDatasByUrl(url, "checkOAMToken", parameter));
        if(!jsonResult.isEmpty()) {
	    	if("success".equals(jsonResult.getString("success"))){
	    		userDetail.setUserid(jsonResult.optString("uid"));
	    	}
        }
    	return userDetail;
	}

}
